package com.fenghuajueli.lib_net.common;

import com.blankj.utilcode.util.ToastUtils;

/**
 * 处理token异常问题相关
 *
 * @param <T>
 */
public abstract class TokenObserver<T> extends com.fenghuajueli.lib_net.common.ResponseObserver<T> {

    public abstract void onError(String message);


    public abstract void onTokenError(int code, String message);


    @Override
    public void onFail(int errorCode, String message) {
        if (isShowToast()) {
            ToastUtils.showShort(message);
        }
        if (errorCode == ErrorCode.TOKEN_ERROR) {
            onTokenError(errorCode, message);
        } else {
            onError(message);
        }
    }

    @Override
    public boolean isShowToast() {
        return true;
    }
}
